package phoenix.web.test_objects.data_providers;

import phoenix.core.PhoenixManager;
import phoenix.core.base.extensions.TestBaseExt;
import phoenix.core.data_models.PriceLinkDataModel;
import phoenix.core.data_models.PriceLinkDataModel.CreditsPrices;
import phoenix.core.data_models.UserProfileDataModel;
import phoenix.core.data_models.UserProfileDataModel.PaymentDetails;

/**
 * Class contains test data for Payment page
 */
public class PaymentDataProviders extends TestBaseExt
{
	public PaymentDataProviders(PhoenixManager p_phoenix)
	{
		super(p_phoenix);
	}

	public Object[][] paymentData()
	{
		UserProfileDataModel profileModel = new UserProfileDataModel(manager);
		PaymentDetails paymentDataUnSuccessful = profileModel.new PaymentDetails();
		PaymentDetails paymentDataSuccessful = profileModel.new PaymentDetails();
		paymentDataUnSuccessful.fillUpIncorrectCard();
		paymentDataSuccessful.fillUpCorrectCard();

		return new Object[][]
		{
				// Negative test
				{ paymentDataUnSuccessful, false },
				// Positive test
				{ paymentDataSuccessful, true }
		};
	}

	public Object[][] paymentDataSuccess()
	{
		UserProfileDataModel profileModel = new UserProfileDataModel(manager);
		PaymentDetails paymentDataSuccessful = profileModel.new PaymentDetails();
		paymentDataSuccessful.fillUpCorrectCard();

		return new Object[][]
		{
				// Positive test
				{ paymentDataSuccessful, true }
		};
	}

	public Object[][] paymentCardNumberValidation()
	{
		return new Object[][]
		{
				// Negative test
				{ "", "card_number", false },
				{ "aaaabbbbccccddddeeee", "card_number", false },
				{ "4012aaaabbbbcccc", "card_number", false },
				{ "40128888", "card_number", false },
				{ "!@#$%", "card_number", false },
				{ "     ", "card_number", false },
				// Positive test
				{ "4012888888881881", "card_number", true },
		};
	}

	public Object[][] paymentCardNameValidation()
	{
		return new Object[][]
		{
				// Negative test
				{ "", "card_name", false },
				{ "   ", "card_name", false },
				// Positive test
				{ "Mark Shelton", "card_name", true },
		};
	}

	public Object[][] paymentCardSecurityCodeValidation()
	{
		return new Object[][]
		{
				// Negative test
				{ "", "card_code", false },
				{ "aaaabbbbccccddddeeee", "card_code", false },
				{ "4012aaaabbbbcccc", "card_code", false },
				{ "!@#$%", "card_code", false },
				{ "     ", "card_code", false },
				{ "51", "card_code", false },
				{ "52112", "card_code", false },
				// Positive test
				{ "521", "card_code", true },
				{ "5214", "card_code", true },
		};
	}

	public Object[][] paymentExpiryDateValidation()
	{
		String[] date = manager.cronos().getCurrentDate().split("/");
		String prev_month = Integer.toString(Integer.parseInt(date[1]) - 1);
		String next_month = Integer.toString(Integer.parseInt(date[1]) + 1);
		String next_year = Integer.toString(Integer.parseInt(date[0]) + 1);

		if (prev_month.length() == 1)
		{
			prev_month = "0" + prev_month;
		}

		if (next_month.length() == 1)
		{
			next_month = "0" + next_month;
		}

		return new Object[][]
		{
				// Negative test
				{ prev_month, date[0], "card_date", false },
				// Positive test
				{ date[1], date[0], "card_date", true },
				{ next_month, date[0], "card_date", true },
				{ prev_month, next_year, "card_date", true },
				{ date[1], next_year, "card_date", true },
				{ next_month, next_year, "card_date", true },
		};
	}

	public Object[][] paymentDataPrices()
	{
		PriceLinkDataModel prices = new PriceLinkDataModel(manager);

		return new Object[][]
		{
				// Positive test
				{ prices }
		};
	}

	public Object[][] paymentDataCredits()
	{
		PriceLinkDataModel prices = new PriceLinkDataModel(manager);
		CreditsPrices credits = prices.new CreditsPrices();

		return new Object[][]
		{
				// Positive test
				{ credits }
		};
	}

	public Object[][] paymentDataAuthorization()
	{
		UserProfileDataModel profileModel = new UserProfileDataModel(manager);
		PaymentDetails paymentDataSuccessful = profileModel.new PaymentDetails();
		paymentDataSuccessful.fillUpCorrectCard();

		return new Object[][]
		{
				// Positive test
				{ paymentDataSuccessful }
		};
	}
}
